package com.lian.hope.service.Impl;

import com.lian.hope.mapper.NotificationMapper;
import com.lian.hope.model.dto.NotificationDTO;
import com.lian.hope.model.po.Notification;
import com.lian.hope.model.vo.NotificationVO;
import com.lian.hope.service.NotificationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
@Slf4j
@RequiredArgsConstructor
public class NotificationServiceImpl implements NotificationService {
    private final NotificationMapper notificationMapper;

    @Override
    public List<NotificationVO> getNotification(Long userId, Integer notificationType) {
        return notificationMapper.getNotification(userId, notificationType);
    }

    @Override
    public List<NotificationVO> getSystemNotification(Long userId) {
        return notificationMapper.getSystemNotification(userId);
    }

    @Override
    public List<NotificationVO> getActivityNotification(Long userId) {
        return notificationMapper.getActivityNotification(userId);
    }

    @Override
    public void insertNotification(NotificationDTO notificationDTO) {

        log.info("receiver_id:{}",notificationDTO.getReceiverId());
        Notification notification = Notification.builder().content(notificationDTO.getContent()).notificationType(
            notificationDTO.getNotificationType()).receiverId(notificationDTO.getReceiverId()).receiverId(notificationDTO.getReceiverId()).sendTime(
            LocalDateTime.now()).build();

        notificationMapper.insertNotification(notification);
    }
}
